<template>
	<!--   -->
	<view class="jy-wrap" v-if="isLogin">
		<bnn-loading :loading="isLoading" />
		<view class="jy-topWrap">
			<view class="jy-content-t">
				<view class="content-text">
					<view class="title-gray">实盘资金<u-icon name="eye-fill"></u-icon>
					</view>
					<view class="text-number">{{contentData.balance}}</view>
				</view>
				<view class="content-text-r">
					<view class="title-gray">资金使用率</view>
					<view class="paogress_class">
						<!--  -->
						<view style="color:#FA3534 ;">{{parseIntFn(contentData.currMargin/Accountprice*100)||0}}%</view>
						<u-line-progress class="progress" active-color="#FF9900" :height="15" round
							:percent="(contentData.currMargin/Accountprice*100).toFixed(2)" :show-percent="false">
						</u-line-progress>
					</view>
				</view>
			</view>
			<view class="jy-content-b">
				<view class="content-l">
					<span class="title-class">总盈亏:</span>
					<span>{{parseInt(contentData.positionProfit+contentData.closeProfit)}}</span>
				</view>
				<view class="content-r">
					<span class="title-class">可用保证金:</span>
					<!-- .toFixed(2) -->
					<span>{{contentData.available}}</span>
				</view>
			</view>
		</view>
		<view class="jy-dataWrap">
			<view class="search-wrap">
				<!-- <view class="dropdown-wrap"> -->
				<!-- <u-dropdown>
						<u-dropdown-item v-model="value" title="螺纹钢2105 rb2105" :options="myFuturesData"></u-dropdown-item>
					</u-dropdown> -->
				<!-- <u-dropdown ref="uDropdown">
						<u-dropdown-item title="属性" menu-icon="search">
							<view class="slot-content">
								<view class="u-text-center u-content-color u-m-t-20 u-m-b-20">其他自定义内容</view>
								<u-button type="primary" @click="closeDropdown">确定</u-button>
							</view>
						</u-dropdown-item>
					</u-dropdown> -->
				<!-- </view> -->
				<view class="search_cont" @click="searchTextFn">
					<view class="">
						{{searchText}} {{chText}}
					</view>
					<u-icon name="arrow-down"></u-icon>
				</view>
				<view class="search" @click="searchFn">
					<image src="https://sou-liang.oss-cn-shanghai.aliyuncs.com/weixin/images/search.png"></image>
				</view>
			</view>
			<u-popup v-model="show" mode="bottom" height="200px" :closeable="true">
				<view class="popup_tit">
					我的自选
				</view>
				<view class="content">
					<view class="cont_item" :class="index==value?'sta':''" v-for="(item,index) in myFuturesData"
						:key="index" @click="clickFutures(index,item.name)">
						{{item.name}}
					</view>
					<!-- <view class="cont_item">
							螺纹钢2105
						</view>
						<view class="cont_item">
							螺纹钢2105
						</view>
						<view class="cont_item">
							螺纹钢2105
						</view> -->
				</view>
			</u-popup>
			<view class="dataView">
				<view class="data-l">
					<view class="data-l-wrap">
						<view class="number-l">{{dealData.last_price}}</view>
						<view class="number-r">
							<view>
								{{dealData.last_price - dealData.pre_settlement> 0 ? '+' + (dealData.last_price - dealData.pre_settlement).toFixed(2) : (dealData.last_price - dealData.pre_settlement).toFixed(2)}}
							</view>
							<view>{{dealData.hl}} %</view>
						</view>
					</view>
				</view>
				<view class="data-r">
					<view class="right-wrap">
						<view class="right-number">
							<view>卖价 <span style="color: #FA3534;margin-left: 5px;">{{dealData.ask_price1}}</span>
							</view>
							<view>买价 <span style="color: #FA3534;margin-left: 5px;">{{dealData.bid_price1}}</span>
							</view>
						</view>
						<view class="right-number">
							<view>卖量 <span style="color: #FA3534;margin-left: 5px;">{{dealData.ask_volume1}}</span>
							</view>
							<view>买量 <span style="color: #FA3534;margin-left: 5px;">{{dealData.bid_volume1}}</span>
							</view>
						</view>
					</view>
				</view>
			</view>
			<view class="acount-wrap">
				<view class="zhangWrap" @click="ToTrading(1,dealData.instrument_id)">
					<view class="zhang-t">
						<image src="https://sou-liang.oss-cn-shanghai.aliyuncs.com/weixin/images/shangzhang.png"></image>
						<span>买涨</span>
					</view>
					<view class="zhang-b">
						<span>后市价格上涨盈利</span>
					</view>
				</view>
				<view class="dieWrap" @click="ToTrading(2,dealData.instrument_id)">
					<view class="zhang-t">
						<image src="https://sou-liang.oss-cn-shanghai.aliyuncs.com/weixin/images/shujuxiajiangqushixiadie.png"></image>
						<span>买跌</span>
					</view>
					<view class="zhang-b">
						<span>后市价格下跌盈利</span>
					</view>
				</view>
				<view class="pingWrap" @click="ToTrading(3,dealData.instrument_id)">
					<view class="zhang-t">
						<image src="https://sou-liang.oss-cn-shanghai.aliyuncs.com/weixin/images/pingcang.png"></image>
						<span>平仓</span>
					</view>
					<view class="zhang-b">
						<span>先开先平</span>
					</view>
				</view>
			</view>
		</view>
		<view class="table-wrap">
			<u-tabs :list="list" inactive-color="#333" active-color="#fda600" :is-scroll="false" :current="current"
				@change="change"></u-tabs>
			<!-- <view> 
			<u-tabs-swiper ref="uTabs" :list="list" inactive-color="#333" active-color="#fda600" :current="current" @change="tabsChange" :is-scroll="false"
			 swiperWidth="750"></u-tabs-swiper>
			</view> -->
			<!--  {height:screenHeight+'px'}-->
			<swiper :style="{height:screenHeight+'px'}" :current="swiperCurrent" @transition="transition"
				@animationfinish="animationfinish">
				<swiper-item class="swiper-item">
					<!-- 持仓 -->
					<!--  v-for="(item, index) in tabs" :key="index" -->
					<u-table class="positoncont" border-color="#ffffff" padding="10px 0">
						<u-tr class="u-tr">
							<u-th class="u-th" width="30%">合约/方向</u-th>
							<u-th class="u-th" width="30%">可用/总仓</u-th>
							<u-th class="u-th" width="20%">成本价</u-th>
							<u-th class="u-th" width="20%">总盈亏</u-th>
							<!-- <u-th class="u-th" width="20%">总盈亏</u-th> -->
						</u-tr>
						<!-- :class="statebtn?'checked':''" -->
						<scroll-view scroll-y="true" style="height: 400px;width: 100%;">
							<view class="Position" v-for="(item,index) in PositionData" :key="index"
								:class="statebtn==index?'checked':''">
								<view class="" @click="checkedFn(item,index)">
									<!-- <view class="">{{item.posiDirection}},{{item.hedgeFlag}}</view> -->
									<view class="tionitem">
										<view class="item1">
											<text>{{instrumentFn(item.instrumentID)}}</text>
											<text v-if="item.posiDirection==2"
												:style="{color:item.posiDirection==2?'#ff4d59':''}">涨</text>
											<text v-if="item.posiDirection==3"
												:style="{color:item.posiDirection==3?'#3dbf61':''}">跌</text>
										</view>
										<view class="item2">
											{{item.posiDirection==2?item.position-item.shortFrozen:item.position-item.longFrozen}}
											/ {{item.position}}
										</view>
										<view class="item3">{{parseIntFn(item.ageprice/item.agenum)}}</view>
										<!-- <view class="item4"> <text :style="{color:item.positionProfit>0?'#ff4d59':'#3dbf61'}">{{item.ydPosition==0?item.positionProfit:item.ByTrade+item.positionProfit}}</text></view> -->
										<view class="item4"> <text
												:style="{color:item.positionProfit>0?'#ff4d59':'#3dbf61'}">{{parseIntFn(item.positionProfit)}}</text>
										</view>
									</view>
									<view class="Positionbtn checked" v-if="statebtn==index">
										<u-button class="btnStyle" size="mini" @click="ToTrading2(item)">平仓</u-button>
										<u-button class="btnStyle1" size="mini" @click="ToTrading3(item)">止盈止损
										</u-button>
									</view>
								</view>
							</view>

							<u-empty v-if="PositionData.length==0" text="暂无持仓记录" mode="order" margin-top="20"></u-empty>
							<view class="Positionnum" v-if="PositionData.length>0">--共有 {{PositionData.length}} 条持仓记录--
							</view>
						</scroll-view>
					</u-table>
				</swiper-item>
				<swiper-item class="swiper-item">
					<!-- 委托 -->
					<!--  v-for="(item, index) in tabs" :key="index" -->
					<u-table class="positoncont" border-color="#ffffff" padding="10px 0">
						<u-tr class="u-tr">
							<u-th class="u-th" width="25%">合约/方向</u-th>
							<u-th class="u-th" width="15%">状态</u-th>
							<u-th class="u-th" width="25%">可撤/委托</u-th>
							<u-th class="u-th" width="15%">委托价</u-th>
							<u-th class="u-th" width="20%">委托时间</u-th>
						</u-tr>
						<!--  v-for="(item,index) in DeclarationData" :key="index" volumeTotal volumeTraded-->
						<scroll-view scroll-y style="height: 400px;width: 100%;" @scrolltolower="onreachBottom">
							<!-- direction 1卖 0买 -->
							<!-- combOffsetFlag 1平 0跌 -->
							<!-- 卖出+平仓=卖涨，买入+平仓=卖跌 -->
							<!-- 买入+开仓= 买涨，卖出+开仓=买跌 -->
							<view class="Position" v-for="(item,index) in DeclarationData" :key="index">
								<view class="tionitem">
									<view class="Decitem1">
										<text>{{instrumentFn(item.instrumentID)}}</text>
										<view v-if="item.direction==0&&item.combOffsetFlag==0"
											:style="{color:item.direction==0&&item.combOffsetFlag==0?'#ff4d59':'#3dbf61'}">
											买涨</view>
										<view v-else-if="item.direction==1&&item.combOffsetFlag==0"
											:style="{color:item.direction==0&&item.combOffsetFlag==0?'#ff4d59':'#3dbf61'}">
											买跌</view>
										<view v-else-if="item.direction==1&&item.combOffsetFlag==1"
											:style="{color:item.direction==0&&item.combOffsetFlag==0?'#ff4d59':'#3dbf61'}">
											平涨</view>
										<view v-else="item.direction==0&&item.combOffsetFlag==1"
											:style="{color:item.direction==0&&item.combOffsetFlag==0?'#ff4d59':'#3dbf61'}">
											平跌</view>
									</view>
									<view class="Decitem2" v-if="item.stag==0" :class="item.stag==0?'stag':''"
										@click="repealFn(item,index)">可撤</view>
									<view class="Decitem2" v-else-if="item.stag==1">已成交</view>
									<view class="Decitem2" v-else="item.stag==2">已撤单</view>
									<view class="Decitem3">
										{{item.volumeTotalOriginal-item.gnum}}/{{item.volumeTotalOriginal}}
									</view>
									<view class="Decitem4">{{parseInt(item.limitPrice)}}</view>
									<view class="Decitem5">{{item.insertTime}}</view>
								</view>
							</view>
							<u-empty v-if="DeclarationData.length==0" text="暂无委托记录" mode="order" margin-top="20">
							</u-empty>
						</scroll-view>
						<!-- <span :style="{color:item.positionCost>0?'#ff4d59':'#3dbf61'}">{{item.positionCost}}</span> -->
					</u-table>
				</swiper-item>
				<swiper-item class="swiper-item">
					<!-- 条件单 -->
					<u-table class="positoncont" border-color="#ffffff" padding="10px 0">
						<!--  v-for="(item, index) in tabs" :key="index" -->
						<view class="condition_cont">
							<view class="condition_item" :class="condistate==1?'condistate':''"
								@click="condistateFn(1)">
								未触发条件单
							</view>
							<view class="condition_item" :class="condistate==2?'condistate':''"
								@click="condistateFn(2)">
								已触发条件单
							</view>
							<view class="condition_item" :class="condistate==3?'condistate':''"
								@click="condistateFn(3)">
								未触发损盈单
							</view>
							<view class="condition_item" :class="condistate==4?'condistate':''"
								@click="condistateFn(4)">
								已触发损盈单
							</view>
						</view>
						<view class="condition_type">
							<scroll-view scroll-y="true" style="height: 400px;width: 100%;">
								<u-tr class="u-tr" width="100%">
									<u-th class="u-th" width="25%">合约/方向</u-th>
									<u-th class="u-th" width="10%">手数</u-th>
									<u-th class="u-th" width="40%">触发条件</u-th>
									<u-th class="u-th" width="25%">创建时间</u-th>
									<!-- <u-th class="u-th" width="20%">总盈亏</u-th> -->
								</u-tr>
								<!-- width: 900px; -->
								<scroll-view scroll-x="true" style="">
									<view class="type_cont">
										<!-- <view class="condi_item">合约/方向</view>
								<view class="condi_item1">手数</view>
								 <view class="condi_item2">类型</view>
								<view class="condi_item3">触发条件</view>
								<view class="condi_item4">创建时间</view> -->

									</view>
									<view class="Position" v-for="(item,index) in conditionData" :key="index"
										:class="contbtn==index?'checked':''">
										<view class="" @click="contckedFn(condistate,index)">
											<view class="tionitem">
												<view class="conditem1">
													<text>{{instrumentFn(item.instrumentID)}}</text>
													<view v-if="item.direction==0&&item.combOffsetFlag==0"
														:style="{color:item.direction==0&&item.combOffsetFlag==0?'#ff4d59':'#3dbf61'}">
														买涨</view>
													<view v-else-if="item.direction==1&&item.combOffsetFlag==0"
														:style="{color:item.direction==0&&item.combOffsetFlag==0?'#ff4d59':'#3dbf61'}">
														买跌</view>
													<view v-else-if="item.direction==1&&item.combOffsetFlag==1"
														:style="{color:item.direction==0&&item.combOffsetFlag==0?'#ff4d59':'#3dbf61'}">
														平涨</view>
													<view v-else="item.direction==0&&item.combOffsetFlag==1"
														:style="{color:item.direction==0&&item.combOffsetFlag==0?'#ff4d59':'#3dbf61'}">
														平跌</view>
												</view>
												<view class="conditem2">{{item.volumeTotalOriginal}}</view>
												<view class="conditem3">
													<text
														v-if="item.direction==1&&item.combOffsetFlag==1">{{item.contingentCondition=='E'?'止盈(最新价≤':'止损(最新价≥'}}：{{item.stopPrice}})</text>
													<text
														v-else>{{item.contingentCondition=='H'?'止盈(最新价≤':'止损(最新价≥'}}：{{item.stopPrice}})</text>
												</view>
												<view class="conditem4">{{item.insertDate}} {{item.insertTime}}</view>

											</view>
											<view class="Positionbtn checked" v-if="contbtn==index">
												<u-button class="btnStyle2" size="mini"
													@click="Originaldelete(item,index)">删除</u-button>
												<!-- <u-button class="btnStyle1" size="mini" @click="ToTrading3(item)">止盈止损</u-button> -->
											</view>
										</view>
									</view>
								</scroll-view>
								<u-empty class="emp-hight" v-if="conditionData.length==0" text="暂无条件单记录" mode="order"
									margin-top="20"></u-empty>
								<view style="width: 100%; text-align: center;padding: 35rpx;">
									<u-button class="btnStyle2" size="medium"
										@click="tjd(1,dealData.instrument_id,'flag')">添加条件单</u-button>
								</view>
								<view class="condition_msg">
									<!-- <view class=""> -->
									<view class="feng">风险提示：</view>
									<view class="text">1）多个止盈止损，先达到成先触发；</view>
									<view class="text">2）若持仓单无同方向持仓，则未触发止盈止损自动删除；</view>
									<view class="text">3）因期货交易规则，触发不保证能委托成交</view>
									<!-- </view> -->
								</view>
							</scroll-view>
						</view>
					
					
					
					
					</u-table>
			
			
				</swiper-item>
				<swiper-item class="swiper-item">
					<!-- 已成交 -->
					<!--  v-for="(item, index) in tabs" :key="index" -->
					<u-table class="positoncont" border-color="#ffffff" padding="10px 0">
						<u-tr class="u-tr">
							<u-th class="u-th" width="30%">合约/方向</u-th>
							<u-th class="u-th" width="25%">成交手数</u-th>
							<u-th class="u-th" width="20%">成交价</u-th>
							<u-th class="u-th" width="25%">成交时间</u-th>
						</u-tr>
						<scroll-view scroll-y="true" style="height: 400px;width: 100%;">
							<!-- <u-tr class="u-tr" v-for="(item,index) in dataList" :key="index">
								<u-td class="u-td" width="30%">{{item.name}}
									<view :style="{color:item.isZhang?'#ff4d59':'#3dbf61'}">{{item.isZhang?'涨':'跌'}}</view>
								</u-td>
								<u-td class="u-td" width="30%">{{item.acount}}</u-td>
								<u-td class="u-td" width="20%">{{item.price}}</u-td>
								<u-td class="u-td" width="20%">
									<span :style="{color:item.isZhang?'#ff4d59':'#3dbf61'}">{{item.money}}</span>
								</u-td>
							</u-tr> -->
							<u-tr class="u-tr" v-for="(item,index) in marketionData" :key="index">
								<u-td class="u-td" width="30%">{{instrumentFn(item.instrumentID)}}
									<!-- <view class="">{{item.direction}}/{{item.combOffsetFlag}}</view> -->
									<view v-if="item.direction==0&&item.combOffsetFlag==0"
										:style="{color:item.direction==0&&item.combOffsetFlag==0?'#ff4d59':'#3dbf61'}">
										买涨</view>
									<view v-else-if="item.direction==1&&item.combOffsetFlag==0"
										:style="{color:item.direction==0&&item.combOffsetFlag==0?'#ff4d59':'#3dbf61'}">
										买跌</view>
									<view v-else-if="item.direction==1&&item.combOffsetFlag==1"
										:style="{color:item.direction==0&&item.combOffsetFlag==0?'#ff4d59':'#3dbf61'}">
										平涨</view>
									<view v-else
										:style="{color:item.direction==0&&item.combOffsetFlag==0?'#ff4d59':'#3dbf61'}">
										平跌</view>
									<!-- <view v-if="item.closeProfit!=''" :style="{color:item.closeProfit==0?'#ff4d59':'#3dbf61'}">{{PositionData.closeProfit==0?'买涨':'买跌'}}</view> -->
								</u-td>
								<u-td class="u-td" width="25%">{{item.volumeTotalOriginal}}</u-td>
								<u-td class="u-td" width="20%">{{parseInt(item.limitPrice)}}</u-td>
								<u-td class="u-td" width="25%">
									{{item.insertTime}}
								</u-td>
							</u-tr>
							<u-empty v-if="marketionData.length==0" text="暂无成交记录" mode="order" margin-top="20">
							</u-empty>
						</scroll-view>
					</u-table>
				</swiper-item>
			</swiper>
		</view>
		<u-popup v-model="isShow" mode="right">
			<view>
				<u-cell-group>
					<u-cell-item icon="account-fill" title="退出账户" @click="quitClick"></u-cell-item>
					<u-cell-item icon="account-fill" title="结算单" @click="affirm"></u-cell-item>
					<u-cell-item icon="account-fill" title="结算单查询" @click="affirmtime"></u-cell-item>
				</u-cell-group>
			</view>
		</u-popup>
		<u-popup v-model="isweituo" width="70%" mode="center" border-radius="14" :mask-close-able="false">
			<view class="entrust">
				<view class="entrust_text">交易品种：{{globalmodul.instrumentID}}</view>
				<view class="entrust_text">操作：
					<text v-if="globalmodul.direction==0&&globalmodul.combOffsetFlag==0">买涨</text>
					<text v-else-if="globalmodul.direction==1&&globalmodul.combOffsetFlag==0">买跌</text>
					<text v-else-if="globalmodul.direction==1&&globalmodul.combOffsetFlag==1">平涨</text>
					<text v-else>平跌</text>
					<!-- {{globalmodul.direction==0?'买涨':'卖跌'}} -->
					/{{globalmodul.limitPrice}}/{{globalmodul.volumeTotalOriginal}}
				</view>
				<view class="entrust_text">结果：<text class="success">委托成功</text></view>
			</view>
			<view class="entrust_btn" @click="isweituoFn">确定</view>
		</u-popup>
		<u-popup v-model="ischedan" width="70%" mode="center" border-radius="14" :mask-close-able="false">
			<view class="entrust">
				<view class="entrust_text">交易品种：{{chedanmodul.instrumentID}}</view>
				<view class="entrust_text">操作：撤单/{{chedanmodul.limitPrice}}/{{chedanmodul.volumeTotalOriginal}}手</view>
				<view class="entrust_text">结果：<text class="success">撤单成功</text></view>
			</view>
			<view class="entrust_btn" @click="ischedan=false">确定</view>
		</u-popup>
		<u-popup v-model="isjiao" width="70%" mode="center" border-radius="14" :mask-close-able="false">
			<view class="make_cont">
				<view class="make_tit">交易成交通知</view>
				<view class="make_text">{{markemodul.instrumentID}}/
					<text v-if="markemodul.direction==0&&markemodul.combOffsetFlag==0">买涨</text>
					<text v-else-if="markemodul.direction==1&&markemodul.combOffsetFlag==0">买跌</text>
					<text v-else-if="markemodul.direction==1&&markemodul.combOffsetFlag==1">平涨</text>
					<text v-else>平跌</text>
					<!-- {{markemodul.direction==0?'买涨':'买跌'}} -->
					/{{markemodul.volumeTotalOriginal}}手
				</view>
				<view class="make_text">成交价：{{markemodul.limitPrice}}</view>
				<view class="make_btn">
					<view class="bottom bgr" @click="isjiaoFn">取消</view>
					<view class="bottom bgy" @click="isjiaoFn">查看</view>
				</view>
			</view>
		</u-popup>
	</view>
	<view v-else class="noLoginWrap">
		<view class="title-t">
			搜量量化
		</view>
		<u-grid :col="3" :border="false">
			<u-grid-item>
				<u-image width="80rpx" height="80rpx" src="https://sou-liang.oss-cn-shanghai.aliyuncs.com/weixin/images/jisu.png"></u-image>
				<view class="grid-text">极速行情</view>
			</u-grid-item>
			<u-grid-item>
				<u-image width="80rpx" height="80rpx" src="https://sou-liang.oss-cn-shanghai.aliyuncs.com/weixin/images/shandian.png"></u-image>
				<view class="grid-text">闪电下单</view>
			</u-grid-item>
			<u-grid-item>
				<u-image width="80rpx" height="80rpx" src="https://sou-liang.oss-cn-shanghai.aliyuncs.com/weixin/images/caozuo.png"></u-image>
				<view class="grid-text">操作简单</view>
			</u-grid-item>
		</u-grid>
		<!-- <view class="open_text">
			<view class="open_left">
				<u-avatar :src="img" size="50"></u-avatar>
				<view style="padding: 10px;">{{name}}</view>
			</view>
			<view class="open_right" @click="goopenFn">登录 ></view>
		</view> -->
		<!--  v-if="is_login == false" -->
		<view>
			<u-button type="primary" @click="ToLogin">立即开户</u-button>
			<u-button @click="deallogin">已有账号，马上添加</u-button>
		</view>
		<view class="no-bottom">开户由期货保证金监控中心提供</view>
	</view>
</template>


<script>
	// import Vue from 'vue'
	import BnnLoading from '@/components/bnn-ui/loading/index.vue'
	// import {affirmJieSuan} from '@/api/strategy.js'
	import {
		formatMoney
	} from '@/utils/index.js'
	import {
		instrumentName
	} from '@/api/rank.js'
	const dcRichAlert = uni.requireNativePlugin('Trader')
	var globalEvent = uni.requireNativePlugin('globalEvent');
	var globalstr = ''
	var globalData = []
	var markeData = []
	var condData = []
	var condData4 = []
	var Orderjiao = false
	var Orderweituo = false
	var global = ''
	var marke = ''
	var weitimer = null
	let num = 1
	var cenum = -1
	var userid = ''
	var markeid = ''
	var bloAccountId = ''
	const usertion = uni.getStorageSync('userPosition')
	if (usertion) {
		userid = usertion.user + 'userid'
		markeid = usertion.user + 'markeid'
		bloAccountId = usertion.user + 'bloAccountid'
	}
	
      globalEvent.addEventListener('onRtnOrder', function(e) { //报单监听  条件单监听  撤单监听
      	plus.nativeUI.alert('报单监听' + JSON.stringify(e))
      	const usertion = uni.getStorageSync('userPosition')
      	if (usertion) {
      		userid = usertion.user + 'userid'
      		markeid = usertion.user + 'markeid'
      		bloAccountId = usertion.user + 'bloAccountid'
      	}
      	if (userid == '') {
      		// plus.nativeUI.alert('userid' + JSON.stringify(bloAccountId))
      	}
      	if (e.orderStatus == 3) { //委托
      		e.stag = 0
      		e.gnum = 0
      		globalstr = e
      		Orderweituo = true
      		global = e
      		try {
      			// const usertion = uni.getStorageSync('userPosition')
      			const gAccount = uni.getStorageSync(userid)
      			if (gAccount) {
      				const newArr = gAccount
      				newArr.unshift(e)
      				uni.setStorageSync(userid, newArr);
      			} else {
      				globalData.unshift(e)
      				uni.setStorageSync(userid, globalData);
      			}
      			let date = new Date()
      			let year = date.getFullYear()
      			let month = date.getMonth() + 1
      			let day = date.getDate()
      			let getDate = year.toString() + month.toString() + day.toString()
      			uni.setStorageSync('globalTime', getDate);
      		} catch (e) {
      			plus.nativeUI.alert('委托cuowu' + e)
      		}
      	}
      	if (e.orderStatus == 5) { //异常 或 撤单
      		uni.showToast({
      			title: e.statusMsg,
      			icon: 'none'
      		})
      	}
      	if (e.orderStatus == 'a') { //提示报单已提交
      		uni.showToast({
      			title: e.statusMsg,
      			icon: 'none'
      		})
      	}
      	if (e.orderStatus == 'c') { //条件单已触发
      		condData4.unshift(e)
      		try {
      			const overAccount = uni.getStorageSync('overcondAccount')
      			if (overAccount) {
      				overAccount.unshift(e)
      				uni.setStorageSync('overcondAccount', overAccount);
      			} else {
      				uni.setStorageSync('overcondAccount', condData4);
      			}
      		} catch (e) {
      			plus.nativeUI.alert('chufa条件单' + e)
      		}
      	}
      	if (e.orderStatus == 'b') { //条件单
      		condData.unshift(e)
      		try {
      			const cAccount = uni.getStorageSync('condAccount')
      			if (cAccount) {
      				cAccount.unshift(e)
      				uni.setStorageSync('condAccount', cAccount);
      			} else {
      				uni.setStorageSync('condAccount', condData);
      			}
      		} catch (e) {
      			plus.nativeUI.alert('条件单' + e)
      		}
      	}
      	if (e.orderStatus == 0) { //成交
      		markeData.unshift(e)
      		Orderjiao = true
      		marke = e
      		try {
      			const mAccount = uni.getStorageSync(markeid)
      			if (mAccount) {
      				mAccount.unshift(e)
      				uni.setStorageSync(markeid, mAccount);
      			} else {
      				uni.setStorageSync(markeid, markeData);
      			}
      			const bloAccount = uni.getStorageSync(bloAccountId)
      			if (bloAccount) {
      				bloAccount.unshift(e)
      				uni.setStorageSync(bloAccountId, bloAccount);
      			} else {
      				globalData.unshift(e)
      				uni.setStorageSync(bloAccountId, globalData);
      			}
      
      		} catch (e) {
      			plus.nativeUI.alert('成交s' + e)
      		}
      	}
      });
	

	export default {
		components: {
			BnnLoading
		},
		data() {
			return {
				// is_login: false,
				condistate: 3,
				Accountprice: '',
				statebtn: -1,
				contbtn: -1,
				isweituo: false,
				isjiao: false,
				ischedan: false,
				searchText: '螺纹钢2105 rb2105',
				chText: '',
				screenHeight: 450,
				show: false,
				isLogin: true, //控制页面登录是否
				isLoading: false, //是否加载
				value: 0,
				options: [{
						label: '螺纹钢2105 rb2105',
						value: 1,
					},
					{
						label: '螺纹钢2106 tv2106',
						value: 2,
					},
					{
						label: '螺纹钢2205 bu2205',
						value: 3,
					}
				],
				list: [{
					name: '持仓',
					value: 0
				}, {
					name: '委托',
					value: 1
				}, {
					name: '条件单',
					value: 2
				}, {
					name: '成交',
					value: 3
				}],
				current: 0,
				swiperCurrent: 0,
				dataList: [{
					name: '沥青2020',
					acount: '1/1',
					price: '2848',
					money: '4920.00',
					isZhang: false
				}, {
					name: '沥青2021',
					acount: '1/1',
					price: '2848',
					money: '4920.00',
					isZhang: true
				}, {
					name: '沥青2022',
					acount: '1/1',
					price: '2848',
					money: '4920.00',
					isZhang: false
				}, {
					name: '沥青2023',
					acount: '1/1',
					price: '2848',
					money: '4920.00',
					isZhang: true
				}, {
					name: '沥青2024',
					acount: '1/1',
					price: '2848',
					money: '4920.00',
					isZhang: false
				}, {
					name: '沥青2025',
					acount: '1/1',
					price: '2848',
					money: '4920.00',
					isZhang: true
				}, ],
				contentData: [], //账户数据
				myFuturesData: [], //自选
				dealData: [], //行情数据
				dealTime: null, //获取行情定时器
				tradingAccount: null, //获取账户信息定时
				storPosition: null,
				isShow: false,
				PositionData: [], //持仓
				DeclarationData: [], //委托
				marketionData: [], //成交
				conditionData: [], //条件单
				triggerdata: [], //未触发条件单
				triggerdata1: [], //已触发条件单
				triggerdata2: [], //未触发损盈单
				triggerdata3: [], //已触发条件单
				globalmodul: '', //委托弹窗数据
				markemodul: '', //成功弹窗数据
				chedanmodul: '',
				instrumentName: {}, //合约名
			}
		},
		onNavigationBarButtonTap: function(e) {
			// getApp().globalData.isAccount=false
			if (this.isLogin) this.isShow = true;
			else uni.showToast({
				title: '请先登录账户',
				icon: 'none'
			});
		},
		onLoad() {
			instrumentName().then(res => { //获取合约中文名
				this.instrumentName = res.data
			})
		},
		onBackPress() {
			// uni.navigateTo({
			//     url: '../home/index'
			// });
		},
		onShow() {
			let is_login = uni.getStorageSync('dealData')
			if (is_login != null) {
				// this.is_login = true
			}

			let webView = this.$mp.page.$getAppWebview();
			if (getApp().globalData.isAccount) { //是否登录账户
				this.isLogin = true
				if (this.contentData == '') {
					this.isLoading = true
				}
				// if(true){
				let that = this
				webView.setTitleNViewButtonStyle(0, {
					width: '30',
				})

				this.isjiao = Orderjiao
				this.isweituo = Orderweituo

				this.globalmodul = global
				this.markemodul = marke
				if (getApp().globalData.rankDetail == '') { //是否有搜索记录
					this.myFutures(0)
				} else {
					// let item=getApp().globalData.rankDetail
					this.myFutures(getApp().globalData.rankDetail)
				}

				//this.addEventListener()

				this.reqTradingAccount()

				setTimeout(() => {
					this.isLoading = false
					// this.affirm()
				}, 2000)
				try { //获取委托信息
					let user_id = ''
					let markeid = ''
					const usertion = uni.getStorageSync('userPosition')
					if (usertion) {
						user_id = usertion.user + 'userid'
						markeid = usertion.user + 'markeid'
					}
					let value = uni.getStorageSync(user_id); //委托
					let mvalue = uni.getStorageSync(markeid); //成交
					// plus.nativeUI.alert('user_id委托1' + JSON.stringify(markeid))
					// plus.nativeUI.alert('value委托1' + JSON.stringify(mvalue))
					if (mvalue) {
						this.marketionData = mvalue
						// plus.nativeUI.alert('存储2'+JSON.stringify(this.marketionData))
					}
					if (value) {
						let arrValue = value
						let arrmark = mvalue
						try {
							for (let i = 0; i < arrValue.length; i++) {
								for (let j = i + 1; j < arrValue.length; j++) {
									if (arrValue[i].orderLocalID == arrValue[j].orderLocalID) {
										arrValue.splice(j, 1)
										j--;
									}
								}
							}
						} catch (e) {
							plus.nativeUI.alert('循环报错' + JSON.stringify(e))
						}

						if (mvalue) {
							//状态获取
							for (let y = 0; y < arrValue.length; y++) {
								for (let r = 0; r < arrmark.length; r++) {
									if (arrmark[r].instrumentID == arrValue[y].instrumentID && arrmark[r].direction ==
										arrValue[y].direction && arrmark[r].combOffsetFlag == arrValue[y]
										.combOffsetFlag &&
										arrmark[r].orderLocalID == arrValue[y].orderLocalID) {
										// if(arrmark[r].orderLocalID==arrValue[y].orderLocalID){
										arrValue[y].stag = 1
										arrValue[y].gnum = arrmark[r].volumeTotalOriginal
									} else {
										if (arrValue[y].stag == 2) {
											arrValue[y].stag = 2
											arrValue[y].gnum = 1
										} else {
											if (arrValue[y].stag == 1) {

											} else {
												arrValue[y].stag = 0
												arrValue[y].gnum = 0
											}
										}
									}

								}
							}
							// this.DeclarationData=arr
							this.DeclarationData = arrValue
						} else {
							this.DeclarationData = arrValue
						}
					}
				} catch (e) {
					// plus.nativeUI.alert('获取cuo'+JSON.stringify(e))
				}


				try { //条件单
					const condvalue = uni.getStorageSync('condAccount');
					if (condvalue) {
						this.triggerdata2 = condvalue
					}
					const overvalue = uni.getStorageSync('overcondAccount');
					if (overvalue) {
						this.triggerdata3 = overvalue
					}
					if (this.condistate == 1) {
						this.conditionData = this.triggerdata
					} else if (this.condistate == 2) {
						this.conditionData = this.triggerdata1
					} else if (this.condistate == 3) {
						let arrcondvalue = condvalue
						let arrovervalue = overvalue
						if (overvalue) { //去掉已触发盈损
							for (let n = 0; n < this.arrcondvalue.length; n++) {
								for (let m = 0; j < this.arrovervalue.length; m++) {
									if (this.arrovervalue[m].orderLocalID == this.arrcondvalue[n].orderLocalID || this
										.arrovervalue[m].orderSysID == this.arrcondvalue[n].orderSysID) {
										arrcondvalue.splice(n, 1)
									}
								}
							}
						}
						this.triggerdata2 = arrcondvalue
						this.conditionData = this.triggerdata2
						uni.setStorageSync('condAccount', arrcondvalue);
					} else {
						this.conditionData = this.triggerdata3
					}

				} catch (e) {

				}

			} else {
				this.isLoading = false
				this.isLogin = false
				webView.setTitleNViewButtonStyle(0, {
					width: '0',
				});
			}
		},
		onHide() {
			if (this.dealTime) {
				clearInterval(this.dealTime)
				this.dealTime = null
			}
			if (this.tradingAccount) {
				clearInterval(this.tradingAccount)
				this.tradingAccount = null
			}
			if (this.storPosition) {
				clearInterval(this.storPosition)
				this.storPosition = null
			}
		},
		created() {

		},
		mounted() {
			//this.reqTradingAccount()
		},
		methods: {
			tjd(index, id, item) {
				// 'MA107' 'CZCE.RS107'
				uni.navigateTo({
					url: './conditionsOfsingle/index?index=' + index + '&id=' + id + '&item=' + item
				})
			},
			addEventListener() {

			},
			timer() {
				return setTimeout(() => {
					this.reqTradingAccount()
				}, 1200)
			},
			instrumentFn(text) { //合约名转汉字
				let arr = this.instrumentName[text];
				if (arr) {
					return arr
				} else {
					return text
				}
			},
			parseIntFn(num) { //保留两位
				if (num) {
					return num.toFixed(2)
				} else {
					return num
				}
			},
			condistateFn(index) {
				this.condistate = index
				if (index == 1) {
					this.conditionData = this.triggerdata
				} else if (index == 2) {
					this.conditionData = this.triggerdata1
				} else if (index == 3) {
					this.conditionData = this.triggerdata2
				} else {
					this.conditionData = this.triggerdata3
				}
			},
			setSwiperHeight() {
				// this.$nextTick(()=>{
				let query = uni.createSelectorQuery().in(this);
				query.selectAll(".u-table").boundingClientRect();
				query.exec((res) => {
					this.screenHeight = res[0][this.current].height;
				})
				// }
			},
			isweituoFn() {
				this.isweituo = false
				Orderweituo = false
			},
			isjiaoFn() {
				this.isjiao = false
				Orderjiao = false
			},
			checkedFn(item, i) {
				if (this.statebtn == i) {
					this.statebtn = -1
				} else {
					this.statebtn = i
					if (this.dealTime) {
						clearInterval(this.dealTime)
						this.dealTime = null
					}
					this.searchText = this.instrumentName[item.instrumentID]
					this.chText = item.instrumentID
					let id = item.exchangeID + '.' + item.instrumentID
					this.dealdataFn(id)
				}
			},
			contckedFn(n, i) {
				if (n == 3) {
					if (this.contbtn == i) {
						this.contbtn = -1
					} else {
						this.contbtn = i
					}
				}

			},
			flatFn() {},
			affirmtime() { //是否确认结算单
				this.isShow = false
				uni.navigateTo({
					url: '/pages/tabBar/transaction/stetementime/index'
				})
			},
			affirm() {
				this.isShow = false
				uni.navigateTo({
					url: './statement/index'
				})
			},
			reqTradingAccount() { //获取账户信息
				setInterval(() => {
					setTimeout(() => {
						let that = this
							dcRichAlert.reqQrySecAgentTradingAccount({}, function(res) {
								if (that.contentData == '') {}
								//plus.nativeUI.alert('账户' + JSON.stringify(res))
								if (res.code == 200) {
									if (res.data instanceof Object) {
										getApp().globalData.available = res.data.available
										that.Accountprice = res.data.balance
										uni.setStorageSync('balance', res.data.balance)
										res.data.balance = formatMoney(res.data.balance)
										res.data.available = formatMoney(res.data.available)
										uni.setStorageSync('TradingAccount', res.data);
										that.contentData = res.data
										// if(res.data == ''){
										// 	that.contentData = uni.getStorageSync('TradingAccount');
										// 	that.Accountprice = uni.getStorageSync('balance')
										// }
									}
									that.reqInvestorPosition(res.data)
								}
							})
						}, 0)
					}, 2000)
			},
			reqInvestorPosition(item) { //持仓查询
			let thet = this
			//var item = uni.getStorageSync('TradingAccount');
			dcRichAlert.reqQryInvestorPosition({}, function(res) {
			    //plus.nativeUI.alert('持仓'+JSON.stringify(res))
				if (thet.PositionData == '') {
			
				}
				if (Array.isArray(res.data)) {
					// uni.setStorageSync('reqQryposition',res.data);
					let pdata = res.data.filter(function(item) {
						return item.position != 0
					})
					try {
						let data = {
							BrokerID: item.brokerID,
							InvestorID: item.investorID,
							ExchangeID: item.exchangeID,
							InvestUnitID: item.investUnitID,
							// InstrumentID:'j2105'
						}
						dcRichAlert.reqQryInvestorPositionDetail(data, function(ret) {
							//plus.nativeUI.alert('持仓详情' + JSON.stringify(ret))
							// pdata[i]['ByTrade']="0"
							if (Array.isArray(ret.data)) {
								let Ddata = ret.data
								let pnum = pdata.length
								let dnum = Ddata.length
								try {
									let prisenum = 0
									let fitnum = 0
									for (let i = 0; i < pnum; i++) {
										pdata[i]['ageprice'] = 0
										pdata[i]['agenum'] = 0
										for (let j = 0; j < dnum; j++) {
											if (Ddata[j].hasOwnProperty('direction') &&
												Ddata[j].hasOwnProperty('openPrice') &&
												Ddata[j].hasOwnProperty(
													'positionProfitByTrade')) {
												if (pdata[i].posiDirection == 3 && pdata[i]
													.instrumentID == Ddata[j]
													.instrumentID && Ddata[j].direction ==
													Ddata[j].hedgeFlag) {
													pdata[i].ageprice += Ddata[j].openPrice
													pdata[i].agenum += 1
													pdata[i].positionProfit += Ddata[j]
														.positionProfitByTrade
												}
												if (pdata[i].posiDirection == 2 && pdata[i]
													.instrumentID == Ddata[j]
													.instrumentID && Ddata[j].direction !=
													Ddata[j].hedgeFlag) {
													pdata[i].ageprice += Ddata[j].openPrice
													pdata[i].agenum += 1
													pdata[i].positionProfit += Ddata[j]
														.positionProfitByTrade
												}
											}
										}
									}
								} catch (e) {
									// plus.nativeUI.alert('持仓循环报错'+JSON.stringify(e))
								}
								thet.PositionData = pdata
								uni.setStorageSync('reqQryposition', pdata);
								// plus.nativeUI.alert('持仓合并'+JSON.stringify(pdata))
								//持仓多空方向 PosiDirection 2涨  3跌
								//投机套保标志 hedgeFlag
								//买卖 direction 
								// 	// uni.setStorageSync('InvestorPosition', res.data);
							}
			
						})
					} catch (e) {
						plus.nativeUI.alert(e)
					}
				}
				// plus.nativeUI.alert(JSON.stringify(thet.PositionData))
			})
				
			},
			repealFn(item, index) { //撤单
				let thst = this
				let data = {
					ActionFlag: '0', //操作标志
					BrokerID: item.brokerID, //经纪公司代码
					InvestorID: item.investorID, //
					ExchangeID: item.exchangeID, ///交易所代码
					InstrumentID: item.instrumentID, ///合约代码
					UserID: item.userID, ///用户代码
					OrderSysID: item.orderSysID, ///报单编号
					SessionID: item.sessionID, ///会话编号
					OrderRef: item.orderRef, ///报单引用
					FrontID: item.frontID, ///前置编号
					// LimitPrice:item.limitPrice,//
					// VolumeChange:item.volumeTotalOriginal,
					// nRequestID:'1'
				}
				// globalEvent.removeEventListener('onRtnOrder', function(e) {})

				// plus.nativeUI.alert('撤单提交数据'+JSON.stringify(data))
				try {
					let action = 0
					dcRichAlert.reqOrderAction(data, function(res) {
						// plus.nativeUI.alert('撤单回调'+JSON.stringify(res))
						action = 1
						uni.showToast({
							title: res.message,
							icon: 'none'
						})
						if (res.code == 26) {
							item.stag = 2
							// thst.DeclarationData.push(item)
							thst.DeclarationData[index] = item
							// cenum=index
							// thst.chedanmodul=res.data
							// thst.ischedan=true
							let tdata = thst.DeclarationData
							// plus.nativeUI.alert('撤单存数据'+JSON.stringify(tdata))
							try {
								uni.setStorageSync('globalAccount', tdata);
							} catch (e) {
								plus.nativeUI.alert('撤单存' + JSON.stringify(e))
							}
						}
					})
					setTimeout(() => {
						if (action == 0) {
							item.stag = 2
							// thst.DeclarationData.push(item)
							thst.DeclarationData[index] = item
							let rdata = thst.DeclarationData
							// cenum=index
							// plus.nativeUI.alert('撤单存数据2'+JSON.stringify(rdata))
							try {
								uni.setStorageSync('globalAccount', rdata);
							} catch (e) {
								plus.nativeUI.alert('撤单cun' + JSON.stringify(e))
							}
						}
					}, 1000)
				} catch (e) {
					plus.nativeUI.alert('撤单报错' + JSON.stringify(e))
				}
			},
			Originaldelete(item, index) { //删除条件单
				let deletedata = {
					ActionFlag: '0', //操作标志
					BrokerID: item.brokerID, //经纪公司代码
					InvestorID: item.investorID, //
					ExchangeID: item.exchangeID, ///交易所代码
					InstrumentID: item.instrumentID, ///合约代码
					UserID: item.userID, ///用户代码
					OrderSysID: item.orderSysID, ///报单编号
					SessionID: item.sessionID, ///会话编号
					OrderRef: item.orderRef, ///报单引用
					FrontID: item.frontID, ///前置编号
				}
				try {
					dcRichAlert.reqOrderAction(deletedata, function(res) {
						plus.nativeUI.alert('删除条件单回调' + JSON.stringify(res))
						uni.showToast({
							title: res.message,
							icon: 'none'
						})
						if (res.code == 26) {

						}
					})
					setTimeout(() => {
						this.conditionData.splice(index, 1)
						uni.showToast({
							title: '删除成功',
							icon: 'none'
						})
						uni.setStorageSync('condAccount', this.conditionData);
					}, 1000)
				} catch (e) {
					plus.nativeUI.alert('撤单报错' + JSON.stringify(e))
				}
			},
			quitClick() { //退出账户
				let that = this
				uni.showLoading({
					title: '退出中'
				});
				try {
					// uni.removeStorageSync('TradingAccount');

					if (this.dealTime) {
						clearInterval(this.dealTime)
						this.dealTime = null
					}
					if (this.tradingAccount) {
						clearInterval(this.tradingAccount)
						this.tradingAccount = null
					}
					if (this.storPosition) {
						clearInterval(this.storPosition)
						this.storPosition = null
					}
					let rdata = {
						BrokerID: this.contentData.brokerID,
						UserID: this.contentData.accountID
					}
					plus.nativeUI.alert('退出数据' + JSON.stringify(rdata))
					setTimeout(() => {
						dcRichAlert.reqUserLogout(rdata, function(res) {
							// if(){
							plus.nativeUI.alert('账户退出' + JSON.stringify(res))
							if (res.code == 200) {
								uni.hideLoading();
								that.isLogin = false
								getApp().globalData.isAccount = false
								that.isShow = false
								that.PositionData = []
								that.contentData = []
								that.DeclarationData = []
								let webView = that.$mp.page.$getAppWebview();
								webView.setTitleNViewButtonStyle(0, {
									width: '0',
								});
								uni.showToast({
									title: '账户退出成功',
									icon: 'none'
								})
								// plus.nativeUI.alert('账户退出'+JSON.stringify(res))
							} else {
								uni.hideLoading();
								that.isLogin = false
								getApp().globalData.isAccount = false
								that.isShow = false
								that.PositionData = []
								that.contentData = []
								that.DeclarationData = []
								let webView = that.$mp.page.$getAppWebview();
								webView.setTitleNViewButtonStyle(0, {
									width: '0',
								});
								// uni.showToast({title:'账户退出成功',icon:'none'})
								// plus.nativeUI.alert('账户退出'+JSON.stringify(res))
							}
							// }
							// uni.removeStorageSync('globalAccount')
							// uni.removeStorageSync('markeAccount')
						})
					}, 1800)
				} catch (e) {
					// error
					plus.nativeUI.alert('账户退出报错' + JSON.stringify(e))
				}
			},
			searchFn() { //去搜索
				uni.navigateTo({
					url: '../rank/ranksearch/ranksearch?index=1'
				})
			},
			clickFutures(i, name) { //点击改变自选
				uni.showLoading({
					title: '加载中'
				});
				this.searchText = name
				this.value = i
				let {
					instrument_id
				} = this.myFuturesData[i]
				let text = instrument_id.split('.')
				this.chText = text[1]
				if (this.dealTime) {
					clearInterval(this.dealTime)
					this.dealTime = null
				}
				this.dealdataFn(instrument_id)
				this.show = false
				setTimeout(() => {
					uni.hideLoading();
				}, 500)
			},
			myFutures(inment) { //获取自选
				let {
					id
				} = uni.getStorageSync('MEMBER_INFO')
				uni.request({
					url: 'https://md.sou-liang.com/api/myFutures',
					data: {
						id: id
					},
					success: (res) => {
						this.myFuturesData = res.data
						if (inment == 0) {
							this.searchText = res.data[0].name
							let {
								instrument_id
							} = res.data[0]
							let text = res.data[0].instrument_id.split('.')
							this.chText = text[1]
							// this.options
							if (this.dealTime) {
								clearInterval(this.dealTime)
								this.dealTime = null
							}
							this.dealdataFn(instrument_id)
						} else {
							this.searchText = inment.name
							let {
								instrument_id
							} = inment
							let text = inment.instrument_id.split('.')
							this.chText = text[1]
							if (this.dealTime) {
								clearInterval(this.dealTime)
								this.dealTime = null
							}
							this.dealdataFn(instrument_id)
						}
					}
				})
			},
			dealdataFn(n) { //获取行情
				this.dealTime = setInterval(() => {
					uni.request({
						url: 'https://md.sou-liang.com/api/newData',
						data: {
							name: n
						},
						success: (res) => {
							this.dealData = res.data
						}
					})
				}, 1000)
			},
			searchTextFn() {
				this.show = true
			},
			closeDropdown() {
				this.$refs.uDropdown.close();
			},
			change(index) {
				this.current = index;
				this.swiperCurrent = index;
			},
			// tabsChange
			// tabs通知swiper切换
			tabsChange(index) {
				this.current = index;
				this.swiperCurrent = index;

			},
			// swiper-item左右移动，通知tabs的滑块跟随移动
			transition(e) {
				// let dx = e.detail.dx;
				// this.$refs.uTabs.setDx(dx);
			},
			// 由于swiper的内部机制问题，快速切换swiper不会触发dx的连续变化，需要在结束时重置状态
			// swiper滑动结束，分别设置tabs和swiper的状态
			animationfinish(e) {
				let current = e.detail.current;
				// this.$refs.uTabs.setFinishCurrent(current);
				this.swiperCurrent = current;
				this.current = current;
			},
			// scroll-view到底部加载更多
			onreachBottom() {

			},
			ToTrading(index, id) {
				uni.setStorageSync('instrument_id', this.dealData.instrument_id)
				// let id=item.exchangeID+'.'+item.instrumentID
				// let type=0
				// if(item.posiDirection==2){
				// 	type=0 //涨
				// }else{
				// 	type=1 //跌
				// }
				uni.navigateTo({
					url: './trading/index?index=' + index + '&id=' + id
				})
			},
			ToTrading2(item) { //去平仓
				let id = item.exchangeID + '.' + item.instrumentID
				let type = 0
				let prise = item.positionProfit / item.position
				if (item.posiDirection == 2) {
					type = 0 //涨
				} else {
					type = 1 //跌
				}
				uni.navigateTo({
					url: './trading/index?index=3&id=' + id + '&type=' + type + '&prise=' + prise
				})
			},
			ToTrading3(item) { //止盈止损
				let id = item.exchangeID + '.' + item.instrumentID
				let type = 0
				let prise = item.positionProfit / item.position
				if (item.posiDirection == 2) {
					type = 0 //涨
				} else {
					type = 1 //跌
				}
				uni.navigateTo({
					url: './trading/index?index=3&loss=1&id=' + id + '&type=' + type + '&prise=' + prise
				})
			},
			ToLogin() { //去开户
				const user = uni.getStorageSync('MEMBER_INFO')
				if (user) uni.navigateTo({
					url: '/pages/account/open/index'
				});
				else uni.navigateTo({
					url: '/pages/user/login/index?user=1'
				});
			},
			deallogin() { //去登录
				const user = uni.getStorageSync('MEMBER_INFO')
				if (user) uni.navigateTo({
					url: '/pages/user/dealLogin/dealLogin'
				});
				else uni.navigateTo({
					url: '/pages/user/login/index?user=1'
				});
				// alert(1234)
			}
		},
		watch: {
			list() {
				this.timer()
			}
		},
		destroyed() {
			clearTimeout(this.timer())
			clearTimeout(this.reqInvestorPosition())
		},
	}
	//经纪公司代码
	//     TThostFtdcBrokerIDType BrokerID;
	//     ///投资者帐号
	//     TThostFtdcAccountIDType AccountID;
	//     ///上次质押金额
	//     TThostFtdcMoneyType PreMortgage;
	//     ///上次信用额度
	//     TThostFtdcMoneyType PreCredit;
	//     ///上次存款额
	//     TThostFtdcMoneyType PreDeposit;
	//     ///上次结算准备金
	//     TThostFtdcMoneyType PreBalance;
	//     ///上次占用的保证金
	//     TThostFtdcMoneyType PreMargin;
	//     ///利息基数
	//     TThostFtdcMoneyType InterestBase;
	//     ///利息收入
	//     TThostFtdcMoneyType Interest;
	//     ///入金金额
	//     TThostFtdcMoneyType Deposit;
	//     ///出金金额
	//     TThostFtdcMoneyType Withdraw;
	//     ///冻结的保证金
	//     TThostFtdcMoneyType FrozenMargin;
	//     ///冻结的资金
	//     TThostFtdcMoneyType FrozenCash;
	//     ///冻结的手续费
	//     TThostFtdcMoneyType FrozenCommission;
	//     ///当前保证金总额
	//     TThostFtdcMoneyType CurrMargin;
	//     ///资金差额
	//     TThostFtdcMoneyType CashIn;
	//     ///手续费
	//     TThostFtdcMoneyType Commission;
	//     ///平仓盈亏
	//     TThostFtdcMoneyType CloseProfit;
	//     ///持仓盈亏
	//     TThostFtdcMoneyType PositionProfit;
	//     ///期货结算准备金
	//     TThostFtdcMoneyType Balance;
	//     ///可用资金
	//     TThostFtdcMoneyType Available;
	//     ///可取资金
	//     TThostFtdcMoneyType WithdrawQuota;
	//     ///基本准备金
	//     TThostFtdcMoneyType Reserve;
	//     ///交易日
	//     TThostFtdcDateType TradingDay;
	//     ///结算编号
	//     TThostFtdcSettlementIDType SettlementID;
	//     ///信用额度
	//     TThostFtdcMoneyType Credit;
	//     ///质押金额
	//     TThostFtdcMoneyType Mortgage;
	//     ///交易所保证金
	//     TThostFtdcMoneyType ExchangeMargin;
	//     ///投资者交割保证金
	//     TThostFtdcMoneyType DeliveryMargin;
	//     ///交易所交割保证金
	//     TThostFtdcMoneyType ExchangeDeliveryMargin;
	//     ///保底期货结算准备金
	//     TThostFtdcMoneyType ReserveBalance;
	//     ///币种代码
	//     TThostFtdcCurrencyIDType CurrencyID;
	//     ///上次货币质入金额
	//     TThostFtdcMoneyType PreFundMortgageIn;
	///上次货币质出金额
	// TThostFtdcMoneyType PreFundMortgageOut;
	///货币质入金额
	// TThostFtdcMoneyType FundMortgageIn;
	///货币质出金额
	// TThostFtdcMoneyType FundMortgageOut;
	///货币质押余额
	// TThostFtdcMoneyType FundMortgageAvailable;
	///可质押货币金额
	// TThostFtdcMoneyType MortgageableFund;
	///特殊产品占用
</script>

<style lang="scss" scoped>
	.open_text {
		display: flex;
		justify-content: space-between;
		align-items: center;
		padding: 10px 30px 0;
		font-weight: bold;

		.open_left {
			display: flex;
			align-items: center;

			.img {
				width: 20px;
				height: 20px;
				margin-right: 10px;
			}

		}

		.open_right {
			color: #777777;
		}
	}


	.emp-hight {
		height: 100px;
	}

	.type_cont {
		padding: 10px 15px;
		display: flex;

		.condi_item {
			width: 80px;
			text-align: center;
		}

		.condi_item1 {
			width: 60px;
			text-align: center;
		}

		.condi_item2 {
			width: 80px;
			text-align: center;
		}

		.condi_item3 {
			width: 120px;
			text-align: center;
		}

		.condi_item4 {
			width: 120px;
			text-align: center;
		}
	}

	.condition_msg {
		padding: 15px 5px;

		.feng {
			color: #ff4d59;
			font-size: 13px;
		}

		.text {
			font-size: 12px;
			color: #928f8f;
		}
	}

	.condition_cont {
		width: 100%;
		display: flex;
		justify-content: space-around;
		align-items: center;
		padding: 5px;
		background-color: #fff;
		border-top: 1px solid #f9f9f9;

		.condition_item {
			width: 50px;
			// height: 45px;
			font-size: 13px;
			// line-height: 45px;
			text-align: center;
			padding: 2px;
		}

		.condistate {
			border: 1px solid #EFAB00;
			color: #EFAB00;
			border-radius: 5px;
			// background-color: ;
		}
	}

	.u-tr {
		border-bottom: 1px solid #f9f9f9;
	}

	.Position {
		border-bottom: 1px solid #f9f9f9;

		// padding: 5px;
		.tionitem {
			display: flex;
			align-items: center;
			text-align: center;
			padding: 10px 0;

			.item1 {
				width: 30%;
				display: flex;
				flex-direction: column;
			}

			.item2 {
				width: 30%;
			}

			.item3 {
				width: 20%;
			}

			.item4 {
				width: 20%;
			}

			.Decitem1 {
				width: 25%;
				display: flex;
				flex-direction: column;
			}

			.Decitem2 {
				width: 15%;
			}

			.stag {
				border: 1px solid #d3d6d6;
				border-radius: 5px;
				padding: 2px 0;
			}

			.Decitem3 {
				width: 25%;
			}

			.Decitem4 {
				width: 15%;
			}

			.Decitem5 {
				width: 20%;
			}

			.conditem1 {
				width: 25%;
			}

			.conditem2 {
				width: 10%;
			}

			.conditem3 {
				width: 40%;
				display: flex;
				flex-direction: column;
			}

			.conditem4 {
				width: 25%;
			}

		}
	}

	.Positionbtn {
		color: #EFAB00;
		text-align: center;
		// display: flex;
		// justify-content: center;
		margin-bottom: 5px;
		padding: 0 0 5px;
	}

	.checked {
		background-color: #fdfcf7;
	}

	.btnStyle {
		color: #EFAB00;
		border-color: #c0c4cc;
	}

	.btnStyle1 {
		color: #EFAB00;
		border-color: #c0c4cc;
		margin-left: 15px;
	}

	.make_cont {
		padding: 10px;

		.make_tit {
			font-size: 18px;
			font-weight: bold;
			text-align: center;
			margin: 5px 0 10px;
		}

		.make_text {
			line-height: 30px;
		}

		.make_btn {
			display: flex;
			justify-content: space-between;
			text-align: center;
			margin-top: 10px;
			font-size: 16px;

			.bottom {
				width: 48%;
				height: 40px;
				line-height: 40px;
				color: #fff;
				text-align: center;
				border-radius: 10px;
			}

			.bgr {
				background-color: #d3d6d6;
			}

			.bgy {
				background-color: #EFAB00;
			}
		}
	}

	.entrust {
		padding: 10px 15px;
		font-size: 16px;

		.entrust_text {
			line-height: 25px;

			.success {
				color: #EFAB00;
			}
		}
	}

	.entrust_btn {
		width: 100%;
		height: 44px;
		line-height: 44px;
		text-align: center;
		color: #EFAB00;
		font-size: 16px;
		border-top: 1rpx solid #676666;
	}

	.popup_tit {
		width: 100%;
		text-align: center;
		font-size: 16px;
		padding: 10px 0;
	}

	.Positionnum {
		margin-top: 10px;
		font-size: 12px;
		text-align: center;
		color: #e9e9e9;
	}

	.content {
		padding: 24rpx;

		// text-align: center;
		// display: flex;
		// flex-wrap:wrap;
		// justify-content: space-around;
		// align-items:flex-start;
		// align-content: flex-start;
		.cont_item {
			// flex: 0.33;
			width: 30%;
			height: 60rpx;
			display: inline-block;
			line-height: 60rpx;
			text-align: center;
			margin-left: 2%;
			margin-top: 5px;
			border: 1px solid #E8E8E8;
			border-radius: 20rpx;
		}

		.sta {
			border: 1px solid #FDA600;
			color: #FDA600;
		}
	}

	.jy-wrap {
		width: 100%;
		// height: 100vh;
		min-height: 100%;
		background-color: $uni-bg-color-grey;

		.jy-topWrap {
			width: 90%;
			margin-left: 5%;
			background-color: $uni-bg-color;
			height: 230rpx;
			border-radius: 10rpx;
			box-shadow: 0 0 9px 3px #F2F2F2;
			margin-top: 10rpx;

			.jy-content-t {
				width: 90%;
				margin-left: 5%;
				height: 150rpx;
				border-bottom: 1px solid $uni-border-color;
				display: flex;
				padding-top: 20rpx;

				.content-text {
					flex: 1;

					.title-gray {
						color: $uni-text-color-grey;
						font-size: $uni-font-size-lg;
					}

					.text-number {
						color: $uni-text-color;
						font-size: $uni-font-size-lg;
						margin-top: 20rpx;
						font-weight: 600;
					}
				}

				.content-text-r {
					flex: 1;
					text-align: right;

					.paogress_class {
						.progress {
							width: 200rpx;
						}
					}
				}
			}

			.jy-content-b {
				width: 90%;
				margin-left: 5%;
				height: 80rpx;
				display: flex;
				justify-content: flex-start;
				align-items: center;
				font-size: $uni-font-size-base;

				.content-l {
					flex: 1;

					.title-class {
						color: $uni-text-color-grey;
					}
				}

				.content-r {
					flex: 1;
					text-align: right;

					.title-class {
						color: $uni-text-color-grey;
					}
				}
			}
		}
	}

	.jy-dataWrap {
		width: 100%;
		height: 380rpx;
		background-color: $uni-bg-color;
		margin-top: 20rpx;

		.search-wrap {
			width: 100%;
			height: 100rpx;
			padding: 0 10px;
			display: flex;
			justify-content: center;
			align-items: center;
			padding-top: 40rpx;

			.dropdown-wrap {
				width: 90%;
				flex: 5;
				// height: 80rpx;
				// border: 1px solid $uni-border-color;
				// border-radius: 10rpx;
				// margin-left: 5%;
				// text-align: left;
				// line-height: 80rpx;
				// box-shadow: 0 0 9px 3px #F2F2F2;
			}

			.search_cont {
				width: 90%;
				height: 80rpx;
				padding: 0 20rpx;
				flex: 5;
				display: flex;
				justify-content: space-between;
				align-items: center;
				border: 1px solid $uni-border-color;
				border-radius: 10rpx;

			}

			.search {
				flex: 1;

				image {
					width: 50rpx;
					height: 50rpx;
					margin-left: 40rpx;
				}
			}
		}

		.dataView {
			width: 100%;
			height: 100rpx;
			padding-left: 5%;
			display: flex;
			justify-content: flex-start;
			align-items: center;
			margin-top: 20rpx;

			.data-l {
				flex: 1;
				color: red;

				.data-l-wrap {
					margin-top: 20rpx;
					display: flex;
					height: 100rpx;
					align-items: center;

					.number-l {
						// font-size: $uni-font-size-lg;
						font-size: 44rpx;
						font-weight: 600;
					}

					.number-r {
						font-size: $uni-font-size-sm;
						margin-left: 20rpx;
					}
				}

			}

			.data-r {
				flex: 1;

				.right-wrap {
					margin-top: 20rpx;
					display: flex;
					height: 100rpx;
					align-items: center;

					.right-number {
						flex: 1;
						color: $uni-text-color-grey;
						margin-left: 10rpx;
					}
				}
			}
		}

		.acount-wrap {
			width: 90%;
			height: 100rpx;
			margin-left: 5%;
			display: flex;
			justify-content: center;
			align-items: center;
			margin-top: 20rpx;
			color: #FFFFFF;

			.zhangWrap {
				flex: 1;
				height: 100%;
				background-color: #ff4d59;
				text-align: center;
				border-radius: 10rpx;
			}

			.dieWrap {
				flex: 1;
				height: 100%;
				background-color: #3dbf61;
				text-align: center;
				margin-left: 20rpx;
				border-radius: 10rpx;
			}

			.pingWrap {
				flex: 1;
				height: 100%;
				background-color: #fda600;
				text-align: center;
				margin-left: 20rpx;
				border-radius: 10rpx;
			}

			.zhang-t {
				width: 100%;
				display: flex;
				justify-content: center;
				align-items: center;
				margin-top: 10rpx;

				image {
					width: 40rpx;
					height: 40rpx;
				}

				font-size: $uni-font-size-lg;

				span {
					margin-left: 10rpx;
				}
			}

			.zhang-b {
				margin-top: 10rpx;
				font-size: $uni-font-size-sm;
			}
		}
	}

	.table-wrap {
		width: 100%;
		margin-top: 20rpx;
	}

	.noLoginWrap {
		width: 100%;
		height: 100vh;
		background-color: $uni-bg-color;

		.title-t {
			width: 100%;
			text-align: center;
			padding-top: 80rpx;
			// font-family:Georgia;
			// font-family:'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
			font-family: Georgia, 'Times New Roman', Times, serif;
			font-weight: 800;
			font-size: 106rpx;
		}

		.u-grid {
			margin-top: 200rpx;
			margin-bottom: 100rpx;
		}

		.grid-text {
			font-size: 28rpx;
			margin-top: 16rpx;
			color: $u-type-info;
		}

		.u-button {
			margin-top: 50rpx;
		}

		uni-button {
			margin: 40rpx;
		}

		.no-bottom {
			width: 100%;
			height: 50rpx;
			line-height: 50rpx;
			text-align: center;
			position: absolute;
			bottom: 30rpx;
			color: $uni-text-color-grey;
			font-size: $uni-font-size-sm;
		}
	}
</style>
